package com.inspinia.base.mq.util;

import com.inspinia.base.mq.KafkaProducerHelper;
import com.inspinia.base.util.JsonUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 操作消息队列的工具类
 * Created by veblen on 16/5/3.
 */
public class MQUtil {

    /**
     * 日志对象
     */
    protected static Logger logger = LoggerFactory.getLogger(MQUtil.class);

    /**
     * 发送数据
     *
     * @param topic 发送科目
     * @param data  数据
     */
    public static void send(String topic, Object data) {
        String json = JsonUtils.toJson(data);
        KafkaProducerHelper.send(topic, json);
        logger.debug("send data to topic [" + topic + "]:" + json);
    }


}
